import HasRole from '@/components/Permi/hasRole';
import hasPermi from '@/components/Permi/hasPermi';
import IconFont from '@/components/IconFont';
import CommonTable from '@/components/CommonTable';
import CommonSearch from '@/components/CommonSearch';
import CommonTreeselectV2 from '@/components/CommonTreeselectV2';
import CommonDialogForm from '@/components/CommonDialogForm/index.js';
export default {
	install (Vue) {
		Vue.component('HasRole', HasRole);
		Vue.component('hasPermi', hasPermi);
		Vue.component('IconFont', IconFont);
		Vue.component('CommonTable', CommonTable);
		Vue.component('CommonSearch', CommonSearch);
		Vue.component('CommonTreeselectV2', CommonTreeselectV2);
		Vue.use(CommonDialogForm);
		// confirm二次封装
		Vue.config.globalProperties.$hyConfirm = function ({
			title = '提示',
			subTitle = '是否继续?',
			type = 'warning',
			callback = (done) => {
				done();
			}
		} = {}) {
			Vue.config.globalProperties
				.$confirm(subTitle, title, {
					type : type,
					beforeClose : (action, instance, done) => {
						if (action === 'confirm') {
							instance.confirmButtonLoading = true;
							instance.confirmButtonText = '执行中...';
							callback(done);
							instance.confirmButtonLoading = false;
						} else {
							done();
						}
					}
				})
				.then(() => {
					Vue.config.globalProperties.$message({
						type : 'success',
						message : '操作成功!'
					});
				});
		};
	}
};
